﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities.IRepository;
using Entities.PBKT;
using BLToolkit.Data.Linq;
namespace DAL.PBKT
{
    public class BLLichThiDauRepository : ConnectionStringBL, ILichThiDau
    {


        public LichThiDau LayTheoId(string id)
        {
            throw new NotImplementedException();
        }

        public LichThiDau LayChiTietTheoId(string id)
        {
            throw new NotImplementedException();
        }

        public List<LichThiDau> LayTatCa()
        {
            return db.GetTable<LichThiDau>().ToList();
        }

        public bool ThemLichThiDau(LichThiDau ltd)
        {
            try
            {
                int kq = db.Insert(ltd);
                db.CommitTransaction();
                return kq > 0;
            }
            catch (Exception)
            {
                db.RollbackTransaction();
                return false;
            }
        }

        public bool CapNhatLichTHiDau(LichThiDau ltd)
        {
            try
            {
                int kq = db.Update(ltd);
                db.CommitTransaction();
                return kq > 0;
            }
            catch (Exception)
            {
                db.RollbackTransaction();
                return false;
            }
        }

        public bool XoaLichThiDau(LichThiDau ltd)
        {
            try
            {
                int kq = db.Delete(ltd);
                db.CommitTransaction();
                return kq > 0;
            }
            catch (Exception)
            {
                db.RollbackTransaction();
                return false;
            }
        }
    }
}
